home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_11_02
/
1102021a
< prev
next >
Wrap
Text File
|
1992-12-07
|
768b
|
34 lines
/* localtime function */
#include <stdlib.h>
#include "xtime.h"
time_t _Tzoff(void)
{ /* determine local time offset */
static const char *oldzone = NULL;
static long tzoff = 0;
static const long maxtz = 60*13;
if (oldzone != _Times._Tzone)
{ /* determine time zone offset
(East is +) */
const char *p, *pe;
int n;
if (_Times._Tzone[0] == '\0')
_Times._Tzone = _Getzone();
p = _Gettime(_Times._Tzone, 2, &n);
tzoff = strtol(p, (char **)&pe, 10);
if (pe - p != n
|| tzoff <= -maxtz || maxtz <= tzoff)
tzoff = 0;
oldzone = _Times._Tzone;
}
return (-tzoff * 60);
}
struct tm *(localtime)(const time_t *tod)
{ /* convert to local time structure */
return (_Ttotm(NULL, *tod + _Tzoff(), -1));
}